<template>
	<view class="login">
		<view class="header">
			<view class="jt"  @tap="go">
				<
			</view>
		</view>
		
		
		<view class="content">
			<image class="img" src="../../../static/icons/leju-logo.png"    mode=""></image>
			
			<view class="tel">
				<input type="text" v-model="username" />
			</view>
			
			<view class="word">
				<input type="text"  v-model="password"/>
			</view>
			
			<view class="pig" @tap="login">
				
				<text>登录</text>
			</view>
		</view>
	</view>
</template>

<script>
	
	import { doLogin} from "../../../util/user/index.js"
	export default {
		data() {
			return {
				code:'',
				username:'dpq',
				password:'123456'
				
			};
		},
		
		
		
		
		
		
		onLoad(){
			
			
		 },
		 
		 methods:{
		 	go(){
		 		uni.navigateBack({
		 			delta:0
		 		})
		 	},
			// getUserName(e){
			// 	console.log(e)
			// 	this.username=e.detail.value
			// },
			// getPassWord(e){
			// 	console.log(e)
			// 	this.password=e.detail.value
			// },
			
			
			
		 	login(){
				// console.log(this.username,this.password)
				doLogin({
					username:this.username,
					password:this.password
				}).then(res=>{
					console.log(res)
						
					if(res.data.code=="F"){
							uni.showModal({
								content:"用户名或密码错误",
								duration:2000
							})
						}
					else if(res.data.code=="S"){
						uni.showModal({
							content:"输入正确,马上登录",
							duration:2000
						})
						try {
						    uni.setStorageSync('token', "data");
							
								uni.switchTab({
									url:"../user"
								})
								
								({
							
						})
						
						} catch (e) {
						    // error
						}	
					}
					
					this.code=res.data.code
				});	
				
		 	},
			
			
			
			
			
			
			
			
		 },
	}
</script>

<style lang="scss">
.login{
	padding-top: var(--status-bar-height);
}
.header{
	width: 100%;
	height: 60px;
	background-color: #354e44;
	overflow: hidden;
}
.jt{
	font-size: 28px;
	color: #fff;
	margin-top: 10px;
}
.content{
	width: 100%;
	height: 800px;
	background-color: #eeeae5;
}
.img{
	width: 80px;
	height: 80px;
	border-radius: 50%;
	margin-left: 140px;
	margin-top: 80px;
}

.tel{
	width: 300px;
	height: 50px;
	background-color: #f5f5f5;
	border-radius: 30px;
	margin-left: 40px;
	input{
		width: 200px;
		height: 50px;
		background-color: #f5f5f5;
		margin-left: 50px;
		margin-top: 30px;
		
	}
}

.word{
	width: 300px;
	height: 50px;
	background-color: #f5f5f5;
	margin-left: 40px;
	border-radius: 30px;
	input{
		width: 200px;
		height: 50px;
		background-color: #f5f5f5;
		margin-left: 50px;
		margin-top: 30px;
		
	}
}

.pig{
	width: 300px;
	height: 50px;
	background-color: #354e44;
	margin-left: 40px;
	margin-top: 40px;
	border-radius: 30px;
	overflow: hidden;
	text{
		width: 200px;
		height: 50px;
		// background-color: #f5f5f5;
		margin-left: 120px;
		margin-top: 30px;
		line-height: 50px;
		color: #fff;
		font-size: 20px;
		
	}
}


</style>
